﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLTV.Forms.KhaiBao
{
    public partial class frmLichCongTac : BaseForm
    {
        public frmLichCongTac()
        {
            InitializeComponent();
              Database.dsPermission dspermision1 = new Database.dsPermission();
            this.Datasource = dspermision1;
        }
        private void checkPermision()
        {
            btnSua.Enabled = MyPermission.Sua;
            btnThem.Enabled = MyPermission.Sua;
            btnXoa.Enabled = MyPermission.Sua;

            bandedGridView1.OptionsBehavior.Editable = MyPermission.Sua;
        }
        private void frmLichCongTac_Load(object sender, EventArgs e)
        {
            checkPermision();
            // TODO: This line of code loads data into the 'dsUsers.tblNhanSu' table. You can move, or remove it, as needed.
            this.tblNhanSuTableAdapter.Fill(this.dsUsers.tblNhanSu);
            // TODO: This line of code loads data into the 'dsTongQuan.tblLichCongTac' table. You can move, or remove it, as needed.
            this.tblLichCongTacTableAdapter.Fill(this.dsTongQuan.tblLichCongTac);

        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmLichCongTacPopup f = new frmLichCongTacPopup();
            f.isNew = true;
            f.ShowDialog();
            this.tblLichCongTacTableAdapter.Fill(this.dsTongQuan.tblLichCongTac); 
        }

        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (bandedGridView1.FocusedRowHandle > -1)
            {
                frmLichCongTacPopup f = new frmLichCongTacPopup();
                f.isNew=false;
                f._id = Convert.ToInt32(bandedGridView1.GetFocusedRowCellValue("ID"));
                f.ShowDialog();
                this.tblLichCongTacTableAdapter.Fill(this.dsTongQuan.tblLichCongTac);
            }
        }

        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (bandedGridView1.FocusedRowHandle > -1)
            {
                tblLichCongTacBindingSource.RemoveCurrent();
                tblLichCongTacBindingSource.EndEdit();
                tblLichCongTacTableAdapter.Update(dsTongQuan.tblLichCongTac);
                this.tblLichCongTacTableAdapter.Fill(this.dsTongQuan.tblLichCongTac);


            }
        }
    }
}